function getLength(str){
	return str.replace(/[^\x00-xff]/g,"xx").length;
}


window.onload=function(){
	var aInput=document.getElementsByTagName('input');
	var oName=aInput[0];
	var pwd=aInput[1];
	var pwd2=aInput[2];
	var aP=document.getElementsByTagName('p');
	var name_msg=aP[0];
	var pwd_msg=aP[1];
	var pwd2_msg=aP[2];
	var count=document.getElementById('count');
	var aEm=document.getElementsByTagName('em');
	var name_length=0;
	
	var re=/[^\w\u4e00-\u9fa5]/g;
	
	//用户名
	oName.onfocus=function(){
		name_msg.style.display="block";
		name_msg.innerHTML='<i class="ati"></i>5-25个字符，一个汉字为两个字符'
	}
	
	oName.onkeyup=function(){
		count.style.visibillity="visible";
		name_length=getLength(this.value);
		count.innerHTML=name_length+"个字符";
		if(name_length==0){
			count.style.visibillity="hidden";
		}
	}
	 
	oName.onblur=function(){
		//含有非法字符
		var re=/[^\w\u4e00-\u9fa5]/g;
		if(re.test(this.value)){
			name_msg.innerHTML='<i class="err"></i>含有非法字符！'
		}
	}
	
}